package com.gitee.feizns.explore.data_structure.tree.bs.mid;

/**
 * 二叉树剪枝
 * @author feizns
 * @since 2020/3/10
 */
public class PruneTree {

    public static void main(String[] args) {

    }

    public static TreeNode pruneTree(TreeNode root) {
        if ( root != null ) {
            root.left = pruneTree(root.left);
            root.right = pruneTree(root.right);
            return root.left == null && root.right == null && root.val == 0 ? null : root;
        }
        return null;
    }

}
